Question 1: Design a function person-double-name that takes a Person and returns a Person just like the given one, except that the Person and all of his descendants have their names doubled. For example,
(person-double-name (make-person "chuck" (list (make-person "alice" empty) (make-person "bob" empty)))) = (make-person "chuckchuck" (list (make-person "alicealice" empty) (make-person "bobbob" empty)))
Try doing it by straightforward structural decomposition, and then try it again using HOFC. Remember that you will only learn something if you actually do it yourself.
Question 2: Design the following function:;; person-descendant? : Person String -> Boolean ;; GIVEN: a person and a name ;; RETURNS: true iff that person or any of his/her descendants has ;; that name.
;; EXAMPLES: ;; Given the persons in the lesson: (begin-for-test (check-true (person-descendant? fred "bob")) (check-true (person-descendant? chuck "bob")) (check-false (person-descendant? chuck "eddie")) (check-false (person-descendant? fred "eve")))
Try doing it by straightforward structural decomposition, and then try it again using HOFC.
Last modified: Thu Aug 21 16:51:14 Eastern Daylight Time 2014